package com.mashibing.juc.c_006;


/**
 * synchronized既保证了原子性又保证了可见性
 * @author: Yuanzt
 * @Date: 2021/3/24
 */
public class T implements Runnable{

    private int count = 10;

    @Override
    public synchronized void run() {
        count--;
        System.out.println(Thread.currentThread().getName() + " count " + count);
    }

    public static void main(String[] args) {
        com.mashibing.juc.c_005.T t = new com.mashibing.juc.c_005.T();
        for (int i = 0;i<5;i++){
            new Thread(t,"Thread"+i).start();
        }
    }
}
